package com.ruoyi.tmsdriveracc.controller;

import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.tmsdriveracc.domain.DriverCheck;
import com.ruoyi.tmsdriveracc.domain.Receipt;
import com.ruoyi.tmsdriveracc.service.DriverCheckService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 验收信息操作处理
 *
 * @author 小何
 */
@RestController
@RequestMapping("/drivercheck")
public class DriverCheckController extends BaseController
{
    @Autowired(required = false)
    private DriverCheckService driverCheckService;

    /**
     * 获取待验收列表
     */

    @GetMapping("/list")
    public TableDataInfo list( DriverCheck driverCheck)
    {
        startPage();
        List<DriverCheck> list = driverCheckService.selectDcList(driverCheck);
        return getDataTable(list);
    }

    @Log(title = "导出回执单", businessType = BusinessType.EXPORT)

    @PostMapping("/export")
    public void export(HttpServletResponse response, DriverCheck driverCheck)
    {
        List<DriverCheck> list = driverCheckService.selectDcList(driverCheck);
        ExcelUtil<DriverCheck> util = new ExcelUtil<DriverCheck>(DriverCheck.class);
        util.exportExcel(response, list, "回执单数据");
    }



    /**
     * 确认验收
     */

    @Log(title = "确认验收", businessType = BusinessType.UPDATE)
    @PostMapping("/sure")
    public AjaxResult sure(@RequestBody Receipt receipt)
    {
        return toAjax(driverCheckService.updateDriverCheck(receipt));
    }
}
